package com.xuxiao.service.impl;

import com.xuxiao.common.ReturnUpPa;
import com.xuxiao.entrty.UserInfo;
import com.xuxiao.mapper.UserInfoMapper;
import com.xuxiao.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class UserInfoServiceImpl implements UserInfoService {
    @Autowired
    private UserInfoMapper userMapper;

    @Override
    public UserInfo login(String username, String password) {
        return userMapper.getByUsernameAndPassword(username, password);
    }

    @Override
    public void Register(UserInfo userInfo) {
        userInfo.setCreat(LocalDate.now());
        userMapper.InsertNewUser(userInfo);
    }

    @Override
    public int getByUsernameIsSame(String username) {
        return userMapper.SelectByNameIsSame(username);
    }

    @Override
    public List<UserInfo> getAllUserInfomation() {
        return userMapper.SelectAllUserInformation();
    }

    @Override
    public void updateUserByCustomerID(UserInfo userInfo) {
        userMapper.UpdateUserByID(userInfo);
    }

    @Override
    public UserInfo GetUserByID(String id) {
        return userMapper.SelectByID(id);
    }

    @Override
    public void DeleteByID(List<Integer> ids) {
        userMapper.deleteById(ids);
    }

    @Override
    public List<UserInfo> SelectByName(String name) {
        return userMapper.SelectByName(name);
    }



}
